package com.foo.ui_demo_widge;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.text.InputFilter;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Switch;

public class EditTextActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edittext);

        EditText etDemo = findViewById(R.id.etDemo);
        //设置文本颜色
        etDemo.setTextColor(Color.BLUE);
        //设置提示文本
        etDemo.setHint("输入名字");
        //设置提示文本颜色
        etDemo.setHintTextColor(Color.rgb(0, 200, 200));
        //设置背景颜色
        etDemo.setBackgroundColor(Color.parseColor("#ff00ab"));
        //设置可视宽度
        etDemo.setEms(12);
        //限制输入10个字符
        etDemo.setFilters(new InputFilter[]{
                new InputFilter.LengthFilter(10)
        });

        EditText etPasswordDemo = findViewById(R.id.etPasswordDemo);
        Switch swPassword = findViewById(R.id.swPassword);
        swPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                if (isChecked) {
                    
                }
            }
        });
    }
}